/**
 * Created by lx on 2017/10/19.
 */
/**
 * Created by lx on 2017/10/9.
 */
angular.module('service.equipment', [
        "ngResource",
    ])
    .service('EquipmentService', EquipmentService);
EquipmentService.$inject = ['$resource'];
function EquipmentService($resource) {

    // 通过devid获取设备状态表
    this.getAllStatusByDevId = function (devid, datatime, sucF, errF) {
        var resources = $resource(deviceurl + 'devsta/bytimes/:devid');
        return resources.query({devid: devid, starttime: datatime.starttime, endtime: datatime.endtime}, sucF, errF);
    };

    // 通过devid获取设备电量表
    this.getAllChargeByDevId = function (devid, datatime, sucF, errF) {
        var resources = $resource(deviceurl + 'devele/bytimes/:devid');
        return resources.query({devid: devid, starttime: datatime.starttime, endtime: datatime.endtime}, sucF, errF);
    };

    // 通过devid获取设备状态表
    this.getAllChargeStatusByDevId = function (devid, sucF, errF) {
        var resources = $resource(deviceurl + 'devcharec/:devid');
        return resources.get({devid: devid}, sucF, errF);
    };

    // 通过devid获取在线状态表
    this.getStatusByDevId = function (devid, sucF, errF) {
        var resources = $resource(merchanturl + '/shodev/:devid');
        return resources.get({devid: devid}, sucF, errF);
    };

    // 通过设备获取充电状态
    this.getElectricityStatus = function (devid, shopid, sucF, errF) {
        var resources = $resource(electricity_url + '/devicecontroller/getdevchargestatus');
        return resources.get({devid: devid, shopid: shopid}, sucF, errF);
    };

    // 查找设备
    this.getStatusByAlarm = function (devid, alarm, open, close, sucF, errF) {
        var resources = $resource(foodinfoUrl + 'condev/dev/:devid');
        return resources.get({devid: devid, alarm: alarm, open: open, close: close}, sucF, errF);
    }
}